package com.ogilvy.audi.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.ogilvy.audi.bean.Topic;
import com.ogilvy.audi.dao.TopicDao;
import com.ogilvy.frame.hibernate.BaseDaoImpl;
import com.ogilvy.frame.page.PageTools;
@Repository
public class TopicDaoImpl  extends BaseDaoImpl<Topic> implements TopicDao{
	public PageTools<Topic> selectAll(int pageNo, int pageSize,Map<String,Object> condition){
		System.out.println(condition.get("isHot"));
		StringBuffer hql = new StringBuffer("from Topic as t join t.circle c where 1=1");
		if(condition.get("circleId")!=null){
			hql.append(" and c.circleId =").append(condition.get("circleId"));
		}
		if(condition.get("isHot")!=null){
			hql.append(" and isHot =").append(condition.get("isHot"));
		}
		System.out.println(hql);
		PageTools<Topic> plist = this.findByHql(pageNo, pageSize, hql.toString());
		//PageTools<Circle> plist = null;
		return plist;
		
	}
	public PageTools<Topic> selectAll(Map<String,Object> condition){
		return null;
	}
	public List<Topic> selectNewTopic(){
		return this.getSession().createQuery("from Topic t order by t.crDate desc").list();
	}

}
